package org.zjvis.datascience.web.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zjvis.datascience.common.model.ApiResult;
import org.zjvis.datascience.common.vo.CheckModelVo;
import org.zjvis.datascience.service.CommunityCaseService;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "社区案例")
@RequestMapping("/case")
public class CommunityCaseController {
    @Autowired
    CommunityCaseService communityCaseService;


    @PostMapping("/install")
    @ApiOperation("案例试用")
    public ApiResult<?> caseInstall(@RequestBody Map<String, Long> params) {
        Long caseId = params.get("caseId");

        communityCaseService.caseInstall(caseId.intValue());

        return ApiResult.valueOf("安装成功!");
    }


    @PostMapping("/checkModel")
    @ApiOperation("校验模型")
    public ApiResult<List<CheckModelVo>> checkModel(@RequestBody Map<String, Integer> params) {

        Integer caseId = params.get("caseId");

        return ApiResult.valueOf(communityCaseService.checkModel(caseId.intValue()));

    }
}

/*    @PostMapping("/getModels")
    @ApiOperation("获取案例相关模型")

    public ApiResult<List<CheckModelVo>>getModels(@RequestBody Map<String,Integer> params){

        Integer caseId = params.get("caseId");

       return ApiResult.valueOf(communityCaseService.getModels(caseId.intValue())) ;

    }
}*/
